package com.sanpu.kxe.business.trade.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sanpu.kxe.R;
import com.sanpu.kxe.business.trade.bean.RebTotalOutput;
import com.sanpu.kxe.common.interfaces.UrlConstants;
import com.sanpu.kxe.common.view.ShapeImageView;
import com.sanpu.kxe.jump.imageloader.JKImageLoader;

import java.util.ArrayList;

/**
 * Description：新版收益明细
 * Created by 薛勇军 on 2019/4/16.
 */

public class RebTotalListAdapter extends BaseQuickAdapter<RebTotalOutput, BaseViewHolder> {

    public RebTotalListAdapter() {
        super(R.layout.item_reb_total, new ArrayList<RebTotalOutput>());
    }

    @Override
    protected void convert(BaseViewHolder helper, RebTotalOutput item) {
        if (item != null) {
            helper.setText(R.id.type, TextUtils.isEmpty(item.getRebateType()) ? "-" : item.getRebateType())
                    .setText(R.id.reb, item.getRebateAmount() == null ? "0" : item.getRebateAmount())
                    .setText(R.id.time, TextUtils.isEmpty(item.getRebateTime()) ? "" : item.getRebateTime())
                    .setText(R.id.levelNameTv, TextUtils.isEmpty(item.getLevelName()) ? "" : item.getLevelName());

            TextView vNameTv = helper.getView(R.id.name);
            if (!TextUtils.isEmpty(item.getTradeRealName())) {
                vNameTv.setText(item.getTradeRealName() + "（" + item.getTradeUserName() + "）");
            } else {
                vNameTv.setText("" + item.getTradeUserName() + "");
            }

            TextView vAmount = helper.getView(R.id.amount);
            if (!TextUtils.isEmpty(item.getPayAmount())) {
                vAmount.setText("消费金额:￥" + item.getPayAmount() + "");
                vAmount.setVisibility(View.VISIBLE);
            } else {
                vAmount.setVisibility(View.GONE);
            }

            ShapeImageView levelIv = helper.getView(R.id.levelIv);
            if (!TextUtils.isEmpty(item.getLevelImagePath())) {
                JKImageLoader.getInstance().displayImage(mContext,
                        UrlConstants.getBaseUrl() + item.getLevelImagePath(), levelIv);
            }
        }
    }
}
